﻿CREATE PROCEDURE [sp_ssiscatalog].[get_filteredevents]
		@exec_id			BIGINT												/*Specify which execution we want to return information for*/
,		@events				NVARCHAR(MAX)	=	N''								/*List of event_names to return*/
AS
BEGIN
		SET NOCOUNT ON;		
		SELECT	[ResultSet]=@events,em.[event_message_id],em.[message_time],em.[message],em.[package_name],em.[event_name],em.[message_source_name],em.[package_path],em.[execution_path],em.[event_message_context_xml]
		FROM	[sp_ssiscatalog].[events](@exec_id) em 
		WHERE	CHARINDEX(em.[event_name],@events) > 0
		ORDER	BY em.[message_time] DESC;
		RAISERROR('%d event_messages returned for events: %s',1,1,@@ROWCOUNT,@events);
END